﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.ObjectModel;

namespace HotCopperUserScanService.Tests
{
    [TestClass]
    public class HotCopperIntegrationTest
    {
        private HotCopperBrowser _hcBrowser;
        private const string _userPage = @"http://hotcopper.com.au/user_profile.asp?uid=83692";

        [TestInitialize]
        public void TestInitialize()
        {
            _hcBrowser = new HotCopperBrowser();
            _hcBrowser.Login("caterer", "automaton", _userPage);
        }

        [TestCleanup]
        public void TestCleanup()
        {
            _hcBrowser.Logoff();
        }

        [TestMethod]
        public void IntegrationTest()
        {
            var html = _hcBrowser.GetPageContent(new Uri(_userPage));
            var posts = Parser.ExtractPosts(html, "", _hcBrowser, 10, new Collection<string>()).ToArray();
            Assert.IsTrue(posts.Any());
        }

    }
}